#include <iostream>
#include <cmath>
#include <climits>

using namespace std;

int main()
{
	int n = 0;
	int num, price;
	cin >> n;

	int money = INT_MAX;
	for (int i = 0; i < 3; i++)
	{
		cin >> num >> price;
		int k = ceil((double)n / num) * price;
		if (k < money) money = k;
	}

	cout << money << endl;
	return 0;
}